﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Repository.Models
{
    /// <summary>
    /// 幼儿家长关系表
    /// </summary>
    public class ChildrenParent : EntityBase
    {
        /// <summary>
        /// 幼儿id
        /// </summary>
        public Guid ChildId { get; set; }

        /// <summary>
        /// 家长Id
        /// </summary>
        public Guid ParentId { get; set; }

        /// <summary>
        /// 家长关系
        /// </summary>
        public EnumParentRelationship Relationship { get; set; }

        /// <summary>
        /// 幼儿
        /// </summary>
        public Childrens? Child { get; set; }

        /// <summary>
        /// 家长
        /// </summary>
        public Parent? Parent { get; set; }

        public override void ConfigureEntity(ModelBuilder builder)
        {
            // 复合主键设置
            builder.Entity<ChildrenParent>()
                .HasKey(e => new { e.ChildId, e.ParentId });

            // 索引设置
            builder.Entity<ChildrenParent>()
                .HasIndex(e => new { e.ParentId, e.ChildId })
                .IsUnique(false);
        }
    }
}
